/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.himilco.ocana.workflow.core.dao;

import com.himilco.ocana.workflow.core.dao.entities.Incident;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author oussema TOUKEBRI
 */
@Stateless
public class IncidentDAL {
    @PersistenceContext(unitName = "PU_OCANA")
    private EntityManager entityManager;
    
 //bug it should be ticket not incident
    public List<Incident> findAll() {
//        initIncidentDALBO();
        Incident ie = new Incident("IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT","IMPORTANT");
        Incident ie2 = new Incident("TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO","TOTO"); 
        entityManager.persist(ie);
        entityManager.persist(ie2);
        javax.persistence.Query query = entityManager.createQuery("SELECT i FROM db_ocana_incidents i");
        List<Incident> results = query.getResultList();
        //Logger.getLogger("").log(Logger.Level.INFO, results.get(0).getIncident_degree()); 
        return results;
    }

    public EntityManager getEntityManager() {
        return entityManager; 
    }

}
